using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Serialization;

namespace Voodoo.Pattern.Random
{
	[CreateAssetMenu(fileName = "PseudoPool", menuName = "Voodoo/Randomize/PseudoPool", order = 1)]
	public class PseudoPool : ScriptableObject
	{
		[FormerlySerializedAs("_Strings")]
		public List<string> _strings;

		public string GetRandomString(int _minCharacterCount = 1, int _maxCharacterCount = -1)
		{
			if (_maxCharacterCount != -1 && _maxCharacterCount < _minCharacterCount)
			{
				Debug.LogWarning("Error string size asked with min:" + _minCharacterCount + " max:" + _maxCharacterCount + " return empty");
				return string.Empty;
			}
			List<string> list = new List<string>(_strings);
			bool flag;
			string text;
			do
			{
				flag = false;
				if (list.Count == 0)
				{
					Debug.LogWarning("No string selection found with min:" + _minCharacterCount + " max:" + _maxCharacterCount + " return empty");
					return string.Empty;
				}
				int index = UnityEngine.Random.Range(0, list.Count);
				text = list[index];
				list.RemoveAt(index);
				if (text.Length <= _minCharacterCount)
				{
					continue;
				}
				if (_maxCharacterCount != -1)
				{
					if (text.Length < _maxCharacterCount)
					{
						flag = true;
					}
				}
				else
				{
					flag = true;
				}
			}
			while (!flag);
			return text;
		}
	}
}
